var express = require('express');
const sql = require('../sql/sql');
var router = express.Router();
const order = require('../sql/order');


/* GET users listing. */
// 获取数据
router.get('/', function(req, res, next) {
  // if(req.session.power < 1){
  //   res.render('order',{
  //     index:4,
  //     power:req.session.power
  //   });
  // }else{
  //   res.send('no power')
  // }
  sql.getData(order).then((data)=>{
    res.render('order',{
      index:4,
      power:req.session.power,
      data
    });
    // console.log(data[0].proData);
  })
});


// 发货
router.get('/deliverGoods', function(req, res, next) {
  let orderNum = req.query.orderNum
  // console.log(orderNum);
  sql.setData(order, {time: orderNum}, {state: 2}).then((data)=>{
    res.redirect('/order')
    console.log(data);
  })
});
module.exports = router;
